﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Aga.Psad.Backend.Repositories;
using Aga.Psad.Backend.Entities;
using System.Globalization;

namespace Aga.Psad.Web
{
    public partial class NuevoAvisoRecepcion : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        
        protected void btnCancelar_Click(object sender, EventArgs e)
        {
            Response.Redirect("AvisosRecepcion.aspx");
        }

        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            string nroLegajo = txtNroLegajo.Text;
            string cuitDeclarante = txtCuitDeclarante.Text;
            string cuitPsad = txtCuitPsad.Text;
            string cuitIE = txtCuitIE.Text;
            string codigo = ddlCodigo.SelectedValue;
            DateTime fechaHoraAcept = DateTime.Parse(txtFechaHoraAceptacion.Text, new CultureInfo("es-AR"));
            string ticket = txtTicket.Text;

            AvisoRecepAcept aviso = new AvisoRecepAcept()
            {
                NroLegajo = nroLegajo,
                CuitDeclarante = cuitDeclarante,
                CuitPsad = cuitPsad,
                CuitIE = cuitIE,
                Codigo = codigo,
                FechaHoraAcept = fechaHoraAcept,
                Ticket = ticket,
                FechaHoraAviso = DateTime.Now,
                EstadoDigitalizacion = 0,
                CodigoError = -1,
                MensajeError = "Sin Enviar"
            };

            AvisoRecepAceptRepository repository = new AvisoRecepAceptRepository();
            repository.Save(aviso);

            Response.Redirect("AvisosRecepcion.aspx");
        }
    }
}
